package mybatis;

import java.io.InputStream;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import com.packages.model.User;

import mybatis.mapper.UserMapper;

public class T1 {
	@Test
	public void 构建(){
		String resource = "/mybatis.xml";
		InputStream inputStream = this.getClass().getResourceAsStream(resource);
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		SqlSession sql = sqlSessionFactory.openSession();
		UserMapper mapper = sql.getMapper(UserMapper.class);
		List<User> list = mapper.list();
		System.out.println(list==null?"0":list.size());

	}
}
